<?php

class GroupFunctions {

    private $_ID;
    private $_groupID;
    private $_functionID;
    private $_view;
    private $_add;
    private $_delete;
    private $_update;
    private $_disable;
    private $_enalble;
    private $_highlight;
    private $_unhighlight;
    
    private $_group;
    private $_function;

    public function getHighlight() {
        return $this->_highlight;
    }

    public function setHighlight($highlight) {
        $this->_highlight = $highlight;
    }

    public function getUnhighlight() {
        return $this->_unhighlight;
    }

    public function setUnhighlight($unhighlight) {
        $this->_unhighlight = $unhighlight;
    }

        public function getFunction() {
        return $this->_function;
    }

    public function setFunction($function) {
        $this->_function = $function;
    }

    public function getID() {
        return $this->_ID;
    }

    public function setID($ID) {
        $this->_ID = $ID;
    }

    public function getGroupID() {
        return $this->_groupID;
    }

    public function setGroupID($GroupID) {
        $this->_groupID = $GroupID;
    }

    public function getFunctionID() {
        return $this->_functionID;
    }

    public function setFunctionID($FunctionID) {
        $this->_functionID = $FunctionID;
    }

    public function getView() {
        return $this->_view;
    }

    public function setView($View) {
        $this->_view = $View;
    }

    public function getAdd() {
        return $this->_add;
    }

    public function setAdd($Add) {
        $this->_add = $Add;
    }

    public function getDelete() {
        return $this->_delete;
    }

    public function setDelete($Delete) {
        $this->_delete = $Delete;
    }

    public function getUpdate() {
        return $this->_update;
    }

    public function setUpdate($Update) {
        $this->_update = $Update;
    }

    public function getDisable() {
        return $this->_disable;
    }

    public function setDisable($Disable) {
        $this->_disable = $Disable;
    }

    public function getEnalble() {
        return $this->_enalble;
    }

    public function setEnalble($Enalble) {
        $this->_enalble = $Enalble;
    }

    public function getGroup() {
        return $this->_group;
    }

    public function setGroup($Group) {
        $this->_group = $Group;
    }

    public function getListByGroupID($db = null) {
        if ($db != null) {

            $sql = 'SELECT 
                    `GF_ID`,
                    `GF_G_ID`,
                    `GF_F_ID`,
                    `GF_View`,
                    `GF_Add`,
                    `GF_Delete`,
                    `GF_Update`,
                    `GF_Disable`,
                    `GF_Enable`,
                    `GF_Highlight`,
                    `GF_UnHighlight`
                    FROM group_functions
                    WHERE GF_G_ID = :GF_G_ID';

            $parameters = array(':GF_G_ID');
            $values = array($this->getGroupID());
            $types = array(PDO::PARAM_INT);

            $result = $db->executeQuery($sql, $parameters, $values, $types);

            // nếu có kết quả
            if ($result != null) {

                // mảng danh sách trả về
                $rows = array();

                // lấy mỗi dòng dữ liệu đưa vào mảng danh sách trả về
                while ($row = $result->fetch()) {

                    $groupFunction = new GroupFunctions();
                    $groupFunction->setID($row->GF_ID);
                    $groupFunction->setGroupID($row->GF_G_ID);
                    $groupFunction->setFunctionID($row->GF_F_ID);
                    $groupFunction->setView($row->GF_View);
                    $groupFunction->setAdd($row->GF_Add);
                    $groupFunction->setDelete($row->GF_Delete);
                    $groupFunction->setUpdate($row->GF_Update);
                    $groupFunction->setDisable($row->GF_Disable);
                    $groupFunction->setEnalble($row->GF_Enable);
                    $groupFunction->setHighlight($row->GF_Highlight);
                    $groupFunction->setUnhighlight($row->GF_UnHighlight);

                    // group
                    $group = new Groups();
                    $group->setID($groupFunction->getGroupID());
                    $group->getByID($db);
                    $groupFunction->setGroup($group);


                    // function 
                    $function = new Functions();
                    $function->setID($groupFunction->getFunctionID());
                    $function->getByID($db);
                    $groupFunction->setFunction($function);

                    $rows[] = $groupFunction;
                }
                return $rows;
            } else {
                return null;
            }
        }
    }

    

}

?>
